Skip to main content

getProvidersRatings

getProvidersRatings

This method retrieves a list of ratings for all providers (agents), optionally including recent user comments.

  1. Retrieve Providers with Ratings

    • Query the rating_provider table for all providers who have:

      • An associated agent
      • Their overall rating and count data
    • If no providers are found, return an empty array (end of process).

  2. (Optional) Fetch Comments

    • Triggered only if includeComments is true.
    • Extract a list of agent IDs from the retrieved providers.
    • Fetch recent comments for these agents, constrained by the optional limit.
  3. Build Provider Ratings Response

    • For each provider:

      • Create a response object with:

        • Agent ID
        • Average Rating
        • Overall Rating Count
      • (If applicable), filter the fetched comments to only include those for this agent and attach them to the response.

  4. Return Final List

    • Return an array of all provider rating responses.
    • Each response may optionally include user comments.